package com.pushtime.service.impl;

import com.pushtime.service.HdfsLogService;
import com.pushtime.domain.HdfsLog;
import com.pushtime.repository.HdfsLogRepository;
import com.pushtime.service.dto.HdfsLogDTO;
import com.pushtime.service.mapper.HdfsLogMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

/**
 * Service Implementation for managing HdfsLog.
 */
@Service
@Transactional
public class HdfsLogServiceImpl implements HdfsLogService {

    private final Logger log = LoggerFactory.getLogger(HdfsLogServiceImpl.class);

    private final HdfsLogRepository hdfsLogRepository;

    private final HdfsLogMapper hdfsLogMapper;

    public HdfsLogServiceImpl(HdfsLogRepository hdfsLogRepository, HdfsLogMapper hdfsLogMapper) {
        this.hdfsLogRepository = hdfsLogRepository;
        this.hdfsLogMapper = hdfsLogMapper;
    }

    /**
     * Save a hdfsLog.
     *
     * @param hdfsLogDTO the entity to save
     * @return the persisted entity
     */
    @Override
    public HdfsLogDTO save(HdfsLogDTO hdfsLogDTO) {
        log.debug("Request to save HdfsLog : {}", hdfsLogDTO);

        HdfsLog hdfsLog = hdfsLogMapper.toEntity(hdfsLogDTO);
        hdfsLog = hdfsLogRepository.save(hdfsLog);
        return hdfsLogMapper.toDto(hdfsLog);
    }

    /**
     * Get all the hdfsLogs.
     *
     * @param pageable the pagination information
     * @return the list of entities
     */
    @Override
    @Transactional(readOnly = true)
    public Page<HdfsLogDTO> findAll(Pageable pageable) {
        log.debug("Request to get all HdfsLogs");
        return hdfsLogRepository.findAll(pageable)
            .map(hdfsLogMapper::toDto);
    }


    /**
     * Get one hdfsLog by id.
     *
     * @param id the id of the entity
     * @return the entity
     */
    @Override
    @Transactional(readOnly = true)
    public Optional<HdfsLogDTO> findOne(Long id) {
        log.debug("Request to get HdfsLog : {}", id);
        return hdfsLogRepository.findById(id)
            .map(hdfsLogMapper::toDto);
    }

    /**
     * Delete the hdfsLog by id.
     *
     * @param id the id of the entity
     */
    @Override
    public void delete(Long id) {
        log.debug("Request to delete HdfsLog : {}", id);
        hdfsLogRepository.deleteById(id);
    }
}
